﻿using Bll;
using Dal;
using MD5Hash;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace yue.Apl.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DengController : ControllerBase
    {
        public DengController(Dbll dbll)
        {
            Dbll = dbll;
        }

        public Dbll Dbll { get; }
        [HttpPost]
        public int dadd(Dengmodel dengmodel)
        {
            return Dbll.dadd(dengmodel);
        }
        [HttpGet]
        public Dengmodel getbyid(int id)
        {
            return Dbll.getbyid(id);
        }
        [HttpGet]
        public Dengmodel getbyname(string shouji)
        {
            return Dbll.getbyname(shouji);
        }
        [HttpGet]
        public List<Dengmodel> dshow()
        {
            return Dbll.dshow();
        }
        [HttpGet]
        public int deng(string shouji,string mima)
        {
            var deng=getbyname(shouji);
            if(deng==null)
            {
                return -1;
            }
            if(deng.Mima!=mima.GetMD5())
            {
                return -2;
            }
            return 1;
        }
    }
}
